package org.dhy.autoconfigure;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//minio自动装配类
@Configuration
//@EnableConfigurationProperties 相当于把使用 @ConfigurationProperties的类注入。
@EnableConfigurationProperties({MinioProperties.class})
//没有MinioAutoConfigure类型的bean时，当前配置类才会生效
@ConditionalOnMissingBean(type ="org.dhy.autoconfigure")
public class MinioAutoConfigure
{
    private final MinioProperties minIo;

    @Autowired
    public MinioAutoConfigure(MinioProperties minIo)
    {
        this.minIo=minIo;
    }

    @Bean
    @ConditionalOnMissingBean
    public MinIOTemplate minIOTemplate()
    {
        return new MinIOTemplate(minIo);
    }

}
